/**
 * @type {String}
 *
 * @properties={typeid:35,uuid:"B51739FC-6682-428E-A462-EDFA6E1E121D"}
 */
var fBusqueda = null;


/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @private
 *
 * @properties={typeid:24,uuid:"F288B4A5-8569-4A60-8C5A-C421BDA959A6"}
 */
function verCarrito(event) {
	plugins.window.showFormPopup(elements.lbl_verCarrito,forms.carrito_compras_win, forms.menu_arriba, 'fVariable')
}

/**
 * Callback method for when form is shown.
 *
 * @param {Boolean} firstShow form is shown first time after load
 * @param {JSEvent} event the event that triggered the action
 *
 * @private
 *
 * @properties={typeid:24,uuid:"9054DA12-F719-4969-9208-BEA7A88168F2"}
 */
function onShow(firstShow, event) {
	if (globals.gUsuarioId != null)
	{
		elements.grp_carrito.visible = true
	}
	else
	{
		elements.grp_carrito.visible = false
	}
	elements.grp_login.visible = !elements.grp_carrito.visible
	fBusqueda = null
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @private
 *
 * @properties={typeid:24,uuid:"C08D1885-20C2-4510-B7F1-38DAC41074AE"}
 */
function ingresar(event) {
	var win = application.createWindow("LOGIN", JSWindow.WINDOW);
	win.title = "Login";
	forms.login.controller.show(win);
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @private
 *
 * @properties={typeid:24,uuid:"D75B8BCA-D727-44C0-852D-00EB33876D82"}
 */
function registrar(event) {
	globals.show('registro_usuario')
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @private
 *
 * @properties={typeid:24,uuid:"43A29B51-A647-4787-85AE-AF1C2A1848B2"}
 * @AllowToRunInFind
 */
function buscar(event) {
	forms.productos_tbl.controller.find()
	
	forms.productos_tbl.productos_to_prod_categorias.descripcion 	= '#%' + fBusqueda + '%'
	forms.productos_tbl.controller.newRecord()
	
	forms.productos_tbl.productos_to_prod_marcas.descripcion 		= '#%' + fBusqueda + '%'
	forms.productos_tbl.controller.newRecord()
	
	forms.productos_tbl.productos_to_prod_subcategorias.descripcion = '#%' + fBusqueda + '%'
	forms.productos_tbl.controller.newRecord()
	
	forms.productos_tbl.descripcion = '#%' + fBusqueda + '%'
	
	forms.productos_tbl.controller.search()
	
	globals.show('productos_tbl')
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @private
 *
 * @properties={typeid:24,uuid:"FB8C7531-6778-48E9-8257-2786A30BA198"}
 */
function verPedidos(event) {
	globals.show('pedidos_ant_tbl')
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @private
 *
 * @properties={typeid:24,uuid:"15C1C8DC-FC37-4DE1-AAE0-4158D177789D"}
 */
function verCuenta(event) {
	globals.show('usuario_dtl')
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"060E34BE-01D9-4F69-957C-E8249A005064"}
 */
function salir(event) {
	globals.gUsuarioId 	= null
	databaseManager.addTableFilterParam('infocom','fac_cabecera','cliente_id','=',0)
	forms.menu_arriba.elements.grp_carrito.visible 	= false
	forms.menu_arriba.elements.grp_login.visible 	= true
}
